#include<bits/stdc++.h>
using namespace std;
const int N=1e5+7;
int T,n,m,L,V,ans,cnt,num,d[N],v[N],a[N],p[N],sum[N];
double t[N],s[N],e[N];
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    scanf("%d",&T);
    while(T--)
    {
        scanf("%d%d%d%d",&n,&m,&L,&V);
        ans=0;cnt=0;num=0;
        for(int i=1;i<=n;i++)
        {
            scanf("%d%d%d",&d[i],&v[i],&a[i]);
            if(a[i]!=0)
            {
                if(v[i]<=V && a[i]<0)
                {
                    t[i]=INT_MAX;
                    s[i]=INT_MAX;
                    e[i]=INT_MAX;
                }
                else if(v[i]>V && a[i]>0)
                {
                    t[i]=0;
                    s[i]=d[i];
                    e[i]=L;
                }
                else if(v[i]<=V && a[i]>0)
                {
                    t[i]=double(double(V-v[i]/1.0)/a[i]/1.0)+1e-6;
                    s[i]=double(v[i]*t[i]*1.0)+double(0.5*a[i]*t[i]*t[i])+double(d[i]/1.0);
                    if(s[i]>L)
                    {
                        s[i]=INT_MAX;
                        e[i]=INT_MAX;
                    }
                    else e[i]=L;
                }
                else if(v[i]>V && a[i]<0)
                {
                    t[i]=double(double(V-v[i]/1.0)/a[i]/1.0)-1e-6;
                    s[i]=double(v[i]*t[i]*1.0)+double(0.5*a[i]*t[i]*t[i])+double(d[i]/1.0);
                    if(s[i]>L)
                    {
                        s[i]=d[i];
                        e[i]=L;
                    }
                    else
                    {
                        e[i]=s[i];
                        s[i]=d[i];
                    }
                }
            }
            else
            {
                t[i]=INT_MAX;
                if(v[i]>V)s[i]=d[i],e[i]=L;
                else s[i]=INT_MAX,e[i]=INT_MAX;
            }
        }
        for(int i=1;i<=m;i++)scanf("%d",&p[i]);
        sort(p+1,p+n+1);
        for(int i=1;i<=n;i++)
        {
            if(s[i]>p[m])continue;
            int tmp1=lower_bound(p+1,p+n+1,s[i])-p,tmp2=upper_bound(p+1,p+n+1,e[i])-p;
            if(tmp2-tmp1>=1)
            {
                ans++;
                for(int j=tmp1;j<tmp2;j++)
                sum[j]++;
            }
        }
        for(int i=1;i<=m;i++)
        {
            if(sum[i]==0)continue;
            cnt+=sum[i];
            num++;
            if(cnt>=ans)break;
        }
        printf("%d %d",ans,m-num);
    }
    return 0;
}
